April 22, 2015

Outline

  • Why the effort?

  • offsetGridText
    • Data preparation
    • Specifying pos manually
    • Automated label positioning via thigmophobe
    • Shadow text functionality via grid.stext
  • Summary

Why the effort?

Why the effort?

Position specifiers

text

  • adj
  • pos and offset (overrides adj)

grid.text

  • just
  • hjust and vjust (overrides just)

Why the effort?

Related problems

offsetGridText code snippets

offsetGridText

Case study

offsetGridText

Case study (incl. research sites)

offsetGridText

Data preparation

# # install 'Rsenal' package
# library(devtools, quietly = TRUE)
# install_github("environmentalinformatics-marburg/Rsenal")

# load package
library(Rsenal)

# spatial data
load("data/osm_kili.RData")

# print trellis object
print(p)

offsetGridText

Specifying pos manually

# enter viewport
downViewport(trellis.vpname(name = "figure"))

# labels
ch_lbl <- shp_kili_sls$PlotID

# insert text
offsetGridText(x = coordinates(shp_kili_sls), 
               labels = ch_lbl, 
               xlim = num_xlim, ylim = num_ylim,
               pos = rep(1, length(ch_lbl)), offset = .0225, 
               gp = gpar(fontsize = 20))

offsetGridText

Specifying pos manually

offsetGridText

Automated label positioning via thigmophobe

# insert text
offsetGridText(x = coordinates(shp_kili_sls), 
               labels = ch_lbl, 
               xlim = num_xlim, ylim = num_ylim,
               offset = .0225, 
               gp = gpar(fontsize = 20))

offsetGridText

Automated label positioning via thigmophobe

offsetGridText

Shadow text functionality via grid.stext

# insert text
offsetGridText(x = coordinates(shp_kili_sls), 
               labels = ch_lbl, stext = TRUE, 
               xlim = num_xlim, ylim = num_ylim,
               offset = .0225, 
               gp = gpar(fontsize = 20))

offsetGridText

Shadow text functionality via grid.stext

Summary

Summary

offsetGridText

  • included in Rsenal package (hosted on GitHub)
  • combines text and grid.text positioning arguments
  • compatible with thigmophobe
  • features shadow text

Side note